package za.org.jcicada.syshealth;

import java.awt.Color;
import java.util.EnumMap;
import java.util.Map;

import za.org.jcicada.genss.sensor.ISensor;
import za.org.jcicada.genss.sensor.SensorStatus;

public class SensorColourMap {

	/** Map from sensor status to colour */
	static Map<SensorStatus, Color> colourMap = new EnumMap<SensorStatus, Color>(SensorStatus.class);
	
	static {
		colourMap.put(SensorStatus.UNKNOWN, Color.LIGHT_GRAY);
		colourMap.put(SensorStatus.NOMINAL, Color.GREEN);
		colourMap.put(SensorStatus.WARN, Color.ORANGE);
		colourMap.put(SensorStatus.ERROR, Color.RED);
		colourMap.put(SensorStatus.FAILURE, Color.BLACK);
	}
	
	public static Color getSensorColor(ISensor sensor) {
		SensorStatus status;
		if (sensor == null) {
			status = SensorStatus.UNKNOWN;
		} else {
			status = sensor.getStatusValue().getStatus();
		}
		return colourMap.get(status);
	}
	

}
